<template>
<div>
    <div class="top">
      <span @click="fh">></span>
    </div>
   <van-swipe class="my-swipe" :autoplay="3000" indicator-color="white">
      <van-swipe-item v-for="(item, index) in list" :key="index">
        <img :src="`http://websong.wang:4000/static/imgs${item.icon}`" alt="" />
      </van-swipe-item>
</van-swipe>
<p v-for="(item, index) in list" :key="index" >
  {{item.goods_name}}
  <br>
  <span>￥{{item.group_price}}</span><span>￥{{item.market_price}}</span>
  </p>

<div class="di">
<van-goods-action>
  <van-goods-action-icon icon="chat-o" v-isLogin="{
    action:callService}
    " text="客服" />
     <van-goods-action-icon v-isLogin="{action:()=>{this.$router.push('/cart')}}
       " icon="cart-o" text="购物车"  />
  <van-goods-action-icon icon="shop-o" text="店铺" />
  <van-goods-action-button color="#be99ff" type="warning" v-isLogin="{action:goto,path:'addCart'}" text="加入购物车" />
  <van-goods-action-button color="#7232dd" type="danger" v-isLogin="{action:goto,path:'by'}" text="立即购买" />
</van-goods-action>
</div>

  
</div>
     
 
</template>

<script>
import {mapGetters} from "vuex"
import * as api from"@/api/cart";

import { AsdDsd } from "../../api/goods";
export default {
  data() {
    return {
      list:[],
      id: this.$route.query.id,
      goods:{}
     
    };
  },
  mounted() {
    //发起自动请求
    api.getDetail({
        id:this.id
     }).then((res=>{
      //  console.log(res);
       this.goods=res.data.result[0]
     }))
    this.getdetail();
    
  },
  //写事件
  methods: {
    getdetail() {
      AsdDsd({ id: this.id }).then((res) => {
        // this.dd = res.data.result[0];
        this.list = res.data.result
        // this.group_price=res.data.result[0].group_price;
      });
    },
    fh() {
      this.$router.push("/home");
    },

   
    //呼叫客服
    callService(){
     this.$router.push('/socket')
    },
    //请求接口
    goto(type){
      var {goods_id,normal_price,icon,goods_name}=this.goods
        api[type]({
         goods_id:goods_id, 
         uid:this.uid, 
         count:1,
          price:normal_price, 
          goods_name:goods_name, 
          icon:icon
       }).then(({data})=>{
         console.log(data);
       })
      // console.log(this.goods);
    
     
    }
    
  
   
  },
  computed: {
    
    ...mapGetters(['uid'])
   
  },
  //注册
  components: {},
};
</script>

<style lang='scss' scoped>
.top {
  width: 100%;
  height: 30px;
  border-bottom: 1px solid #ccc;
  font-size: 20px;
}
img{
  width: 100%;
  height: 200px;
}
.d1{
  z-index: 999;
  margin-top: -200px;
}


</style>
